package com.myproject.zhujiemian;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.itheima.tencentqq52.R;
import com.myproject.database.MYdatabase;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SimpleAdapter;


public class AddTask extends Activity{

	private MYdatabase taskDB;
	private SQLiteDatabase baseWriter;
	private EditText tasktext;
//	private Button savebt, deletebt;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.addtask);
//		savebt = (Button) findViewById(R.id.save);
//		deletebt = (Button) findViewById(R.id.delete);
		tasktext = (EditText) findViewById(R.id.text_task);

		taskDB = new MYdatabase(this);
		baseWriter = taskDB.getWritableDatabase();
	}

	public void addDB(){
		ContentValues cv = new ContentValues();
		cv.put(MYdatabase.CONTENT, tasktext.getText().toString());
		cv.put(MYdatabase.TIME, getTime());
		baseWriter.insert(MYdatabase.TABLE_NAME, null, cv);
	}

	private String getTime() {
		SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
		Date curDate = new Date();
		String str = format.format(curDate);
		return str;
	}
	
//	private String getTime() {
//		SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
//		Date curDate = new Date();
//		String str = format.format(curDate);
//		return str;
//	}

	public void do_save(View v) {
		addDB();
		finish();
	}

	public void do_delete(View v) {
		finish();
	}
	
}
